package ${packageName}.controller;

import com.mybatisflex.core.paginate.Page;
import wave.common.pojo.enums.RStatusEnum;
import wave.common.pojo.entity.Result;
import com.wave.wavesystem.common.util.Condition;
import com.wave.wavesystem.common.util.Func;
import ${packageName}.pojo.entity.${humpName}Entity;
import ${packageName}.service.${humpName}Service;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;

/**
* @author ${authorName}
* @date ${generateDate}
* @description ${tableComment} 访问层
*/
@RestController
@RequestMapping("/${ignoreFirstHumpName}")
public class ${humpName}Controller {

    @Resource
    private ${humpName}Service ${ignoreFirstHumpName}Service;

    /**
    * 新增
    *
    * @param ${ignoreFirstHumpName} 新增实体
    */
    @Operation(summary = "保存")
    @PostMapping("/save")
    public Result<${humpName}Entity> save(@RequestBody ${humpName}Entity ${ignoreFirstHumpName}) {
        ${ignoreFirstHumpName}Service.save(${ignoreFirstHumpName});
        return Result.data(${ignoreFirstHumpName});
    }

    /**
    * 删除/批量删除
    *
    * @param ids id集合
    */
    @Operation(summary = "删除")
    @PostMapping("/remove")
    public Result<Boolean> remove(String ids) {
        List<String> idList = Func.strToStringList(ids);
        return Result.status(${ignoreFirstHumpName}Service.removeByIds(idList),RStatusEnum.SUCCESS);
    }

    /**
    * 更新
    *
    * @param ${ignoreFirstHumpName} 更新内容
     */
     @Operation(summary = "更新")
     @PostMapping("/update")
     public Result<${humpName}Entity> update(@RequestBody ${humpName}Entity ${ignoreFirstHumpName}) {
         ${ignoreFirstHumpName}Service.updateById(${ignoreFirstHumpName});
         return Result.data(${ignoreFirstHumpName}Service.getById(${ignoreFirstHumpName}.getId()), RStatusEnum.SUCCESS);
     }

     /**
     * 详情查询
     *
     * @param ${ignoreFirstHumpName} 查询条件
     */
     @Operation(summary = "详情")
     @GetMapping("/detail")
     public Result<${humpName}Entity> detail(${humpName}QueryRequest ${ignoreFirstHumpName}) {
          return Result.data(${ignoreFirstHumpName}Service.getById(${ignoreFirstHumpName}.getId()));
     }

      /**
       * 列表查询
       *
       *@param ${ignoreFirstHumpName}QueryRequest 查询条件
       */
       @Operation(summary = "列表")
       @GetMapping("/list")
       public Result<List<${humpName}Entity>> list(${humpName}QueryRequest ${ignoreFirstHumpName}QueryRequest) {
                        ${humpName}Entity ${ignoreFirstHumpName}= new ${humpName}Entity();
           Func.beanCopy(${ignoreFirstHumpName}QueryRequest, ${ignoreFirstHumpName});
            return Result.data(${ignoreFirstHumpName}Service.list(Condition.getQueryWrapper(${ignoreFirstHumpName})));
       }

       /**
       * 条件分页查询
       *
       * @param ${ignoreFirstHumpName}QueryRequest 查询条件
       */
       @Operation(summary = "分页")
       @GetMapping("/page")
       public Result<Page<${humpName}Entity>> page(${humpName}QueryRequest ${ignoreFirstHumpName}QueryRequest) {
            ${humpName}Entity ${ignoreFirstHumpName} = new ${humpName}Entity();
            Func.beanCopy(${ignoreFirstHumpName}QueryRequest, ${ignoreFirstHumpName});
             return Result.data(${ignoreFirstHumpName}Service.page(
                            Condition.getPage(${ignoreFirstHumpName}QueryRequest),
             Condition.getQueryWrapper(${ignoreFirstHumpName})));
       }

}